package com.wjb.xietong.ota.tab4;

import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import com.wjb.xietong.R;
import com.wjb.xietong.ota.BaseOTA;

public class OTASuggestion extends BaseOTA {

	private EditText suggEditText;
	private Button commitBtn;

	private Dialog dialog;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentField(getLayoutInflater().inflate(R.layout.page_suggestion,
				null));

		setTopBarAndAction(getResources().getString(R.string.STR_SETTING_03),
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						app_.getActManager().popActivity();
					}
				}, null);

	}

	@Override
	protected void findView(View v) {
		// TODO Auto-generated method stub
		super.findView(v);
		suggEditText = (EditText) v.findViewById(R.id.et_suggestion);
		commitBtn = (Button) v.findViewById(R.id.btn_commit);
	}

	@Override
	protected void setOnClickEvent() {
		// TODO Auto-generated method stub
		super.setOnClickEvent();
		commitBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				requestCommitSuggest();
			}
		});
	}

	private void requestCommitSuggest() {
		showProgressDialog();
		//提交反馈信息
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		showCommitSuccessDialog();
	}

	private void showCommitSuccessDialog() {
		dialog = new Dialog(OTASuggestion.this, R.style.CustomDialog);
		dialog.setContentView(R.layout.page_suggestion_dialog);
		Button btnClose = (Button) dialog.findViewById(R.id.btn_close);
		btnClose.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				dialog.dismiss();
				app_.getActManager().popActivity();
			}
		});
		dialog.setCanceledOnTouchOutside(false);
		dialog.show();
	}
}
